import redis
import logging


class Config(object):
    SECRET_KEY = 'ewqewqeqw'
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:13855918018@127.0.0.1:3306/information12"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True  # 数据库操作完成之后自动提交
    LEVEL = logging.DEBUG
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # 配置session存储信息
    SESSION_TYPE = "redis"  # 指定存储类型
    SESSION_PERMANENT = False  # 需要过期
    SESSION_USE_SIGNER = True  # 需要签名存储
    SESSION_REDIS = redis.StrictRedis(REDIS_HOST, REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = 3600 * 24 * 2  # 设置session过期时间2天, 单位秒


class DevelopConfig(Config):
    pass


class ProductConfig(Config):
    DEBUG = False
    LEVEL = logging.ERROR


class TestConfig(Config):
    # 开启测试模式
    TESTING = True


config_dict = {
    'develop': DevelopConfig,
    'product': ProductConfig,
    'test': TestConfig
}
